﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;

namespace CoreData
{
  public  class Subject_Teacher
    {
      public long ID { get; set; }
      public long TeacherID { get; set; }
      public long SubjectID { get; set; }
      public bool IsDeleted { get; set; }
      [Description("Môn học")]
      public string SubjectExt { get; set; }
      [Description("Tên giáo viên")]
      public string TeacherExt { get; set; }

      public Subject_Teacher()
      {
          SubjectExt = ""; TeacherExt = "";
          IsDeleted = false;
      }

      static Subject_Teacher DynamicCast<T>(object row_data, object row_header) where T : Subject_Teacher
      {
          // row_data : DataRow
          // row_header : DataColumnCollection
          Subject_Teacher ret = new Subject_Teacher();
          DataRow dt = (DataRow)row_data;

          foreach (DataColumn column in (DataColumnCollection)row_header)
          {
              switch (column.ColumnName)
              {
                  case "ID":
                      ret.ID = ConvertObject.ToLong(dt[column]);
                      break;
                  case "SubjectID":
                      ret.SubjectID = ConvertObject.ToLong(dt[column]);
                      break;
                  case "TeacherID":
                      ret.TeacherID = ConvertObject.ToLong(dt[column]);
                      break;
                  case "TeacherName":
                      ret.TeacherExt = ConvertObject.ToString(dt[column]);
                      break;
                  case "SubjectName":
                      ret.SubjectExt = ConvertObject.ToString(dt[column]);
                      break;
                  case "IsDeleted":
                      ret.IsDeleted = ConvertObject.ToBool(dt[column]);
                      break;
                  default:
                      break;
              }
          }

          return ret;
      }
        
    }
}
